home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 12 / Amiga Format AFCD12 (Apr 1997, Issue 96).iso / -in_the_mag- / html_tutorial / convert.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1997-01-21  |  1KB  |  59 lines

  1. #!/bin/bash
  2.  
  3. #Edit these to reflect your own machine
  4. #These reflect the curently values in the files
  5.  
  6. export MY_HOST_ONE="snowwhite.it.bton.ac.uk"
  7. export MY_HOST_TWO="www.brighton.ac.uk"
  8. export MY_PATH="~mas"
  9. export MY_RECORD_FILE="~mas\/htp\/mas_logs"
  10. export MY_DIR="~mas\/mas\/courses\/html"
  11.  
  12. #Example edits - so change these
  13.  
  14. export MY_HOST_ONE="hyperion"
  15. export MY_HOST_TWO="hyperion"
  16. export MY_PATH="~www\/..\/"
  17. export MY_RECORD_FILE="~www\/..\/logs\/mas_logs"
  18.  
  19. # Start of conversion
  20. # Do not change anything beyond this line
  21.  
  22. export DIRECTORY=`pwd`
  23. echo "Converting .htm files to .html"
  24. cat <<+END+ > __convert2
  25. echo \$1
  26. sed -f $DIRECTORY/__convert3 < \$1 > \$1l
  27. +END+
  28.  
  29. cat <<+END+ > __convert3
  30. s/snowwhite.it.bton.ac.uk/$MY_HOST_ONE/g
  31. s/snowwhite.it.brighton.ac.uk/$MY_HOST_ONE/g
  32. s/www.brighton.ac.uk/$MY_HOST_TWO/g
  33. s/www.bton.ac.uk/$MY_HOST_TWO/g
  34. s/~mas\/mas\/courses\/html/$MY_DIR/g
  35. s/~mas\/htp\/mas_logs/$MY_RECORD_FILE/g
  36. s/~mas/$MY_PATH/g
  37. s/\.htm/\.html/g
  38. s/\.htmll/\.html/g
  39. s/$//
  40. +END+
  41. find . -name "*.htm" \
  42.        -exec sh $DIRECTORY/__convert2 {} ";"
  43. rm -f __convert2 __convert3
  44.  
  45.  
  46. echo "Removing ^M from .cpp .h and .ada files"
  47. cat <<+END+ > __convert2
  48. echo \$1
  49. sed -f $DIRECTORY/__convert3 < \$1 > \$1.xxx
  50. mv \$1.xxx \$1
  51. +END+
  52.  
  53. cat <<+END+ > __convert3
  54. s/$//
  55. +END+
  56. find . "(" -name "*.cpp" -o -name "*.h" -o -name "*.ada" -o -name "*.htm" ")" \
  57.        -exec sh $DIRECTORY/__convert2 {} ";"
  58. rm -f __convert2 __convert3
  59.